﻿@using ZBJF.Warranty.WebProvider
@{
    ViewBag.Title = "Index";
}
@section Header{
    @Scripts.Render("~/bundles/datatable")
    @Styles.Render("~/Content/datatable")
}
@using ZBJF.Warranty.Common.Enums.InsuranceOrder
@model ZBJF.Warranty.Model.InsuranceOrder
<ul class="nav nav-tabs">
    <li class="active"><a href="/InsuranceWarrantyRecord">订单搜索</a></li>
</ul>
<form id="searchForm" class="breadcrumb form-search">
    <table class="keep-all">
        <tr>
            <td>保单号：</td>
            <td>
                @Html.TextBoxFor(m => m.ThirdOrderNO, new { @class = "input-small" })
            </td>
            <td>被保险人：</td>
            <td>@Html.TextBoxFor(m => m.UserName, new { maxlength = 15, @class = "input-small" })</td>
            <td>被保险人电话：</td>
            <td>@Html.TextBoxFor(m => m.UserPhone, new { maxlength = 15, @class = "input-small" })</td>
            <td>证件号码：</td>
            <td>@Html.TextBoxFor(m => m.CertificateNO, new { maxlength = 20, @class = "input-medium" })</td>
        </tr>
        <tr>
            <td>第三方承保公司：</td>
            <td>@Html.TextBoxFor(m => m.InsuranceCompany, new { maxlength = 20, @class = "input-small" })</td>
            <td>承保公司分公司：</td>
            <td>@Html.TextBoxFor(m => m.InsuranceCompanyBranch, new { maxlength = 20, @class = "input-small" })</td>
            <td>销售商户：</td>
            <td>@Html.TextBoxFor(m => m.SaleVendorName, new { maxlength = 20, @class = "input-small" })</td>
            <td>设备识别码：</td>
            <td>@Html.TextBoxFor(m => m.IMEI, new { maxlength = 20, @class = "input-medium" })</td>

        </tr>
        <tr>
            <td>保险产品类型：</td>
            <td>
                <select id="InsuranceCategoryName" name="InsuranceCategoryName">
                    <option value="">请选择</option>
                    <option value="碎屏险">碎屏险</option>
                </select>
            </td>
            <td>保险产品名称：</td>
            <td>
                @Html.TextBoxFor(m => m.ProductName, new { maxlength = 20, @class = "input-small" })
            </td>
            <td>保险起止期：</td>
            <td>@Html.TextBoxFor(m => m.ServiceStartTime, new { @class = "Wdate input-small", onclick = "WdatePicker()" })</td>
            <td>保险止期：</td>
            <td>@Html.TextBoxFor(m => m.ServiceEndTime, new { @class = "Wdate input-small", onclick = "WdatePicker()" })
                <input id="btnSubmit" class="btn btn-primary Search-R margin-l-10" type="button" value="查询 " onclick="search();">
                <a id="btnCreatedNoInsuranceOrderIWR" class="btn btn-success  Search-R margin-l-10" href="CreateNoInsuranceOrderIWR" target="_blank">新建无保单案件</a>
            </td>
        </tr>
    </table>
</form>
<div class="table-responsive dataTables_wrapper hidden">
    <table id="insuranceOrderList" class="table table-striped table-bordered table-hover">
        <thead>
            <tr>
                <th width="20">序号</th>
                <th>第三方保单号</th>
                <th>设备识别码</th>
                <th>证件号码</th>
                <th>被保险人</th>
                <th>被保险人电话</th>
                <th>保险产品类别</th>
                <th>保险产品名称</th>
                <th>第三方承保公司 </th>
                <th>承保公司分公司 </th>
                <th>销售商户 </th>
                <th>投保时间 </th>
                <th>保险起期</th>
                <th>保险止期</th>
                <th width="60">操作</th>
            </tr>
        </thead>
    </table>
</div>
@section scripts{
    <script type="text/javascript">
        var isSearch = false;
        $(function () {
            var objTable = $("#insuranceOrderList")
                .dataTable({
                    fnDrawCallback: function () {
                        ControlPermissionOperate();
                    },
                    "sAjaxSource": "/InsuranceWarrantyRecord/GetApprovedInsuranceOrder?CanCreatedWarranty=true",
                    aoColumns: [
                        {
                            "mData": null,
                            "bSortable": false,
                            "fnRender": function (nRow) {
                                return nRow.iDataRow + 1;
                            }
                        },
                        { "mData": "ThirdOrderNO" },
                        { "mData": "IMEI" },
                        { "mData": "CertificateNO" },
                        { "mData": "UserName" },
                        { "mData": "UserPhone" },
                        { "mData": "InsuranceCategoryName" },
                        { "mData": "ProductName" },
                        { "mData": "InsuranceCompany" },
                        { "mData": "InsuranceCompanyBranch" },
                        { "mData": "SaleVendorName" },
                        { "mData": "CreateOrderTime" },
                        { "mData": "ServiceStartTime" },
                        { "mData": "ServiceEndTime" },
                        { "mData": null, "bSortable": false }
                    ],
                    "fnRowCallback": function (nRow, aData, iDisplayIndex) {
                        var html = "<a class='Edit-R' href='/InsuranceWarrantyRecord/Create?InsuranceOrderId=" + aData.ID + "' title='新建报案'>新建报案</i></a>";
                        $('td:eq(14)', nRow).html(html);
                    }
                });
        });

        function search() {
            $(".table-responsive").removeClass("hidden");
            queryParamList.ThirdOrderNO = $("#ThirdOrderNO").val();
            queryParamList.UserPhone = $("#UserPhone").val();
            queryParamList.UserName = $("#UserName").val();
            queryParamList.CertificateNO = $("#CertificateNO").val();
            queryParamList.ServiceStartTime = $("#ServiceStartTime").val();
            queryParamList.ServiceEndTime = $("#ServiceEndTime").val();
            queryParamList.IMEI = $("#IMEI").val();
            queryParamList.InsuranceCategoryName = $("#InsuranceCategoryName").val();
            queryParamList.ProductName = $("#ProductName").val();
            queryParamList.SaleVendorName = $("#SaleVendorName").val();
            queryParamList.InsuranceCompany = $("#InsuranceCompany").val();
            queryParamList.InsuranceCompanyBranch = $("#InsuranceCompanyBranch").val();
            //必须输入关键词，否则不显示，给IMEI赋值一个guid
            if (queryParamList.ThirdOrderNO + queryParamList.UserPhone + queryParamList.UserName + queryParamList.CertificateNO + queryParamList.IMEI + queryParamList.ServiceStartTime + queryParamList.ServiceEndTime + queryParamList.SaleVendorName + queryParamList.InsuranceCompany + queryParamList.InsuranceCompanyBranch + queryParamList.InsuranceCategoryName + queryParamList.ProductName == "") {
                //如果都没输入，不展示数据。
                queryParamList.IMEI = "E5D2BFCE-C58A-4AF6-B3AD-8BF4A4C5A2CE";
            }
            $("#insuranceOrderList").dataTable().fnDraw();
        }

    </script>
}

